package org.example.codegenerate.modelext.WebVo.Enum;

public enum EnumJavaMappingDbType {
    dbvarchar(1, "String", "java.lang.String","varchar","String",EnumPageFieldType.文本框.getType()),
    dbInteger(2, "Integer", "java.lang.Integer","int","int",EnumPageFieldType.文本框.getType()),
    dbDouble(3, "Double", "java.lang.Double","double","Double",EnumPageFieldType.文本框.getType()),
    dbdate(4, "Date", "java.util.Date","date","Date",EnumPageFieldType.日期yyyymmdd.getType()),
    dbdatetime(5, "Date", "java.util.Date","datetime","Date",EnumPageFieldType.日期yyyymmdd.getType()),
    dbdecimal(6, "BigDecimal", "java.math.BigDecimal","decimal","Decimal",EnumPageFieldType.文本框.getType()),
    dbtext(7, "String","java.lang.String", "text","Text",EnumPageFieldType.文本框.getType()),
    dbblob(8, "String", "java.lang.String","blob","Blob",EnumPageFieldType.文本框.getType()),
    dbint(2, "int", "java.lang.Integer","int","int",EnumPageFieldType.文本框.getType()),
    dbdouble(3, "double", "java.lang.Double","double","Double",EnumPageFieldType.文本框.getType());


    int code;
    String javatypesimplename;
    String javatypefullname;
    String dbname;
    String currentFrameWorkNeededDbType;
    String pageType;

    EnumJavaMappingDbType(int code, String javatypesimplename, String javatypefullname, String dbname,String currentFrameWorkNeededDbType,String pageType) {
        this.code = code;
        this.javatypesimplename = javatypesimplename;
        this.javatypefullname = javatypefullname;
        this.dbname=dbname;
        this.currentFrameWorkNeededDbType=currentFrameWorkNeededDbType;
        this.pageType=pageType;
    }

    /*
    * 这个方法需要更换一下，对date，及datetime 2个出现会混淆.目前是统一处理，暂时不用变化，因为这2个最后取的currentFrameWorkNeededDbType，都是一样的。
    * 框架中用到的currentFrameWorkNeededDbType，是第一个字母大写
    * */
    public static EnumJavaMappingDbType getBycolumnDefinition(String columnDefinition) {
        for (EnumJavaMappingDbType en : EnumJavaMappingDbType.values()) {
            /*if (StringUtils.equals(en.getDbname(), dbname)) {
                return en;
            }*/
            if(columnDefinition.toLowerCase().contains(en.getDbname().toLowerCase())){
                return en;
            }
        }

        return null;
    }
    public static EnumJavaMappingDbType getByDbJavaTypeName(String javatypesimplename) {
        for (EnumJavaMappingDbType en : EnumJavaMappingDbType.values()) {
            /*if (StringUtils.equals(en.getDbname(), dbname)) {
                return en;
            }*/
            if(javatypesimplename.toLowerCase().contains(en.getJavatypesimplename().toLowerCase())){
                return en;
            }
        }

        return null;
    }
    public static EnumJavaMappingDbType getDefaultPageTypeByJavaTypeFullName(String outerjavatypefullname) {
        for (EnumJavaMappingDbType en : EnumJavaMappingDbType.values()) {

            if(outerjavatypefullname.equalsIgnoreCase(en.getJavatypefullname())){
                return en;
            }
        }

        return null;
    }
    public static EnumJavaMappingDbType getDefaultPageTypeByJavaTypeSinpleName(String outerjavatypesimplename) {
        for (EnumJavaMappingDbType en : EnumJavaMappingDbType.values()) {

            if(outerjavatypesimplename.toLowerCase().equalsIgnoreCase(en.getJavatypesimplename())){
                return en;
            }
        }

        return null;
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getJavatypesimplename() {
        return javatypesimplename;
    }

    public void setJavatypesimplename(String javatypesimplename) {
        this.javatypesimplename = javatypesimplename;
    }

    public String getJavatypefullname() {
        return javatypefullname;
    }

    public void setJavatypefullname(String javatypefullname) {
        this.javatypefullname = javatypefullname;
    }

    public String getDbname() {
        return dbname;
    }

    public void setDbname(String dbname) {
        this.dbname = dbname;
    }

    public String getCurrentFrameWorkNeededDbType() {
        return currentFrameWorkNeededDbType;
    }

    public void setCurrentFrameWorkNeededDbType(String currentFrameWorkNeededDbType) {
        this.currentFrameWorkNeededDbType = currentFrameWorkNeededDbType;
    }

    public String getPageType() {
        return pageType;
    }

    public void setPageType(String pageType) {
        this.pageType = pageType;
    }
}
